{ function GetSelectionProc(var reply:AppleEvent):OSErr; }
procedure FinishAEGetData;
implementation
uses
AERegistry, AEObjects, MyCallProc;
const
MaxPropLevel = 2; { or whatever number of levels you want to support }
type
propArray = array[1..MaxPropLevel] of DescType;
function CallGetSelection (var reply: AppleEvent; proc: UniversalProcPtr): OSErr;
begin
CallGetSelection := CallPascal24(@reply,proc);
end;
var
getdata: ProcPtr;
function PropertyOf (theSpec: AERecord; var propLevel: integer; var properties: propArray): boolean;
var
objSpec: AERecord;
typ, t, prop: DescType;
size: longint;
key: AEKeyword;
err: OSErr;
begin
PropertyOf := false; { we don't know this is a property yet }
if propLevel = 0 then begin { 0 means the Apple Event }
key := keyDirectObject;
end
else begin
key := keyAEContainer;
end;
if AEGetParamDesc(theSpec, key, typeAERecord, objSpec) = noErr then begin
if (AEGetParamPtr(objSpec, keyAEDesiredClass, typeType, typ, @t, 4, size) = noErr) & (t = cProperty) then begin
if (AEGetParamPtr(objSpec, keyAEKeyForm, typeEnumerated, typ, @t, 4, size) = NoErr) & (t = formPropertyID) then begin { this is redundunt, won't hurt to make sure }
if AEGetParamPtr(objSpec, keyAEKeyData, typeType, typ, @prop, 4, size) = NoErr then begin { which of property? }
propLevel := propLevel + 1;
properties[propLevel] := prop;
if AESizeOfParam(objSpec, keyAEContainer, typ, size) = NoErr then begin { property of what }
if typ = typeNull then begin { prop of application, we are done }
PropertyOf := true;
end
else if typ = typeObjectSpecifier then begin { from another object specifer }
if propLevel < MaxPropLevel then { only do it if we have not reach max level }
PropertyOf := PropertyOf(objSpec, propLevel, properties); { go down 1 level }
end; { else it is an error }
end;
end;
end;
end;
err := AEDisposeDesc(objSpec);
end;
end;
function MyGetDataHandler (var event, reply: AppleEvent; theRefcon: longint): OSErr;
var
err: OSErr;
propLevel: integer;
properties: propArray;
begin
theRefcon:=theRefcon; { UNUSED! }
err := errAENoSuchObject;
propLevel := 0; { 0 means we are passing in an Apple Event }
if PropertyOf(event, propLevel, properties) & (propLevel = 2) then begin
if (properties[1] = pContents) & (properties[2] = pSelection) then begin { it is content of selection }